<template>
  <div class="login-panel ">
    <h1 class="title">后台管理系统</h1>
    <el-tabs type="border-card" v-model="currentTab" stretch>
      <el-tab-pane name="account">
        <template #label>
          <span><i class="el-icon-user-solid"></i> 账号登录</span>
        </template>
        <login-account ref="accountRef" />
      </el-tab-pane>
      <el-tab-pane name="phone">
        <template #label>
          <span><i class="el-icon-mobile-phone"></i> 手机登录</span>
        </template>
        <login-phone />
      </el-tab-pane>
    </el-tabs>
    <div class="control-account">
      <el-checkbox v-model="isKeep">记住密码</el-checkbox>
      <el-link type="primary">忘记密码</el-link>
    </div>
    <el-button type="primary" class="login-btn" @click="loginAction"
      >立即登录</el-button
    >
  </div>
</template>

<script lang="ts">
import { defineComponent, ref } from "vue";

import LoginAccount from "./login-account.vue";
import LoginPhone from "./login-phone.vue";

export default defineComponent({
  components: {
    LoginAccount,
    LoginPhone,
  },
  setup() {
    // 类型限制
    // const num = ref<number>(1);

    // 1 定义属性
    const currentTab = ref("account");
    const isKeep = ref(true);
    const accountRef = ref<InstanceType<typeof LoginAccount>>(); // 获取 LoginAccount 导出的类型
    // 2 定义方法
    const loginAction = () => {
      accountRef.value?.accountLoginAction(isKeep.value);
    };
    return {
      currentTab,
      isKeep,
      accountRef,
      loginAction,
    };
  },
});
</script>

<style lang="less" scoped>
.login-panel {
  width: 400px;
  height: 350px;
  .title {
    font-size: 20px;
    text-align: center;
    margin-bottom: 20px;
    padding-top: 10px;
  }

  .control-account {
    margin-top: 12px;
    display: flex;
    justify-content: space-between;
  }

  .login-btn {
    margin-top: 10px;
    width: 100%;
  }
}
</style>
